package com.cqgc.mapper;

import com.cqgc.pojo.dto.CategoryDTO.CategoryPageQueryDTO;
import com.cqgc.pojo.entity.Category;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {


    /**
     * 分页查询
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);

    //新增
    @Insert("insert into category (category_name,create_time,update_time,create_user,update_user)values (#{categoryName},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(Category category);
    //删除分类
    @Delete("delete from category where cid=#{cid}")
    Integer delete(Integer cid);

    /**
     * 修改
     * @param category
     */
    @Update("update category set category_name=#{categoryName},update_time=#{updateTime} where cid=#{cid}")
    void update(Category category);

    /**
     * 根据分类名称查询
     * @param categoryName
     * @return
     */
    @Select("select * from category where category_name=#{categoryName}")
    Category findByCategoryName(String categoryName);

    @Select("select * from category")
    List<Category> findAll();
}
